package com.mo.common.util;

import com.alibaba.excel.EasyExcel;
import org.apache.poi.ss.formula.functions.T;

import java.io.InputStream;
import java.util.List;

/**
 * @author msy
 * @date 2022/3/28
 */
public class EasyExcelUtil {

    /**
     * 导出
     * @param list
     * @param name
     */
    public static void exportExcel(List list, String name, Class clazz) {
        String fileName = getPath() + name + System.currentTimeMillis() + ".xlsx";
        EasyExcel.write(fileName,clazz)
                .sheet()
                .doWrite(list);
    }

    /**
     * 获取当前路径
     * @return
     */
    private static String getPath(){
        return EasyExcelUtil.class.getResource("/").getPath();
    }
}
